import type { AddressItem } from '@/types/address'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useAddressStore = defineStore('address', () => {
  // 选中的地址
  const selectedAddress = ref<AddressItem>()

  // 修改选中地址的方法
  const changeSelectedAddress = (address: AddressItem) => {
    selectedAddress.value = address
  }

  // 返回选中的地址和修改选中地址的方法
  return {
    selectedAddress,
    changeSelectedAddress,
  }
})
